﻿<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage/Admin.master" AutoEventWireup="false" CodeFile="Vyrobci.aspx.vb" Inherits="Pages_Vyrobci" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Hlavni" Runat="Server">
    <asp:SqlDataSource ID="DS_Vyrobci" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DataHorejsi %>" 
        SelectCommand="SELECT [id_vyrobce], [nazev] FROM [T_Vyrobce] ORDER BY id_vyrobce" 
        InsertCommand="INSERT INTO T_Vyrobce VALUES (@nazev)" 
        DeleteCommand="DELETE FROM T_Vyrobce WHERE (id_vyrobce = @id_vyrobce)" 
        
        UpdateCommand="UPDATE T_Vyrobce SET nazev = @nazev WHERE (id_vyrobce = @id_vyrobce)">
        <DeleteParameters>
            <asp:Parameter Name="id_vyrobce" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="nazev" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="nazev" />
            <asp:Parameter Name="id_vyrobce" />
        </UpdateParameters>
    </asp:SqlDataSource>
<h4>Seznam výrobců</h4>
    Záznamů:
    <asp:DropDownList ID="ddl_pageSizeVyrobci" runat="server" AutoPostBack="True">
        <asp:ListItem Selected="True">10</asp:ListItem>
        <asp:ListItem>20</asp:ListItem>
        <asp:ListItem>40</asp:ListItem>
        <asp:ListItem>80</asp:ListItem>
        <asp:ListItem>100</asp:ListItem>
    </asp:DropDownList>
    <asp:GridView ID="GV_Vyrobci" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" DataSourceID="DS_Vyrobci" 
        CellPadding="4" ForeColor="#333333" Width="160px" 
        DataKeyNames="id_vyrobce">
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
        <Columns>
            <asp:BoundField DataField="id_vyrobce" HeaderText="ID" ReadOnly="True">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:BoundField>
            <asp:BoundField DataField="nazev" HeaderText="Název">
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:BoundField>
            <asp:CommandField CancelText="Zrušit" EditText="Upravit" ShowEditButton="True"
                            UpdateText="Uložit" ValidationGroup="Edit" >
            <ControlStyle ForeColor="Blue" />
            </asp:CommandField>
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" OnClientClick="javascript: return confirm('Opravdu chcete záznam smazat?');" Text="Odstranit"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
    <br />
    <h4 style="margin-bottom:1px">
        Přidat výrobce</h4>
    <asp:FormView ID="FV_NovyVyrobce" runat="server" DataSourceID="DS_Vyrobci" DefaultMode="Insert"
        CellPadding="4" ForeColor="#333333">
        <InsertItemTemplate>
            <table>
                <tr>
                    <td>
                        Název:<asp:TextBox ID="Text_NazevTextBox" runat="server" Text='<%# Bind("nazev") %>'
                            ValidationGroup="vyrobceVloz"></asp:TextBox><br />
                        <asp:RequiredFieldValidator ID="Rfv1_insertVyr" runat="server" ControlToValidate="Text_NazevTextBox"
                            ErrorMessage="*" ValidationGroup="vyrobceVloz"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Insert"
                            ValidationGroup="vyrobceVloz" Text="Přidej"></asp:LinkButton>
                    </td>
                </tr>
            </table>
        </InsertItemTemplate>
        <InsertRowStyle Wrap="False" />
        <ItemTemplate>
        </ItemTemplate>
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
    </asp:FormView>
<br />

</asp:Content>

